package com.qf.fmall2202.user.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.qf.fmall2202.user.entity.UserAddr;
import com.qf.fmall2202.user.service.IUserAddrService;
import com.qf.fmall2202.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

@CrossOrigin
@RestController
@RequestMapping("/useraddr")
public class UseraddressController {

    @Autowired
    IUserAddrService userAddrService;

    @GetMapping("/list")
    public R list( Integer userId){

        //根据userID查询 addr表
        UserAddr one = userAddrService.getOne(new LambdaQueryWrapper<UserAddr>().in(UserAddr::getUserId, userId));
        ArrayList<UserAddr> list = new ArrayList<>();

        list.add(one);


        return R.ok().put("data",list);

    }
}
